package simpleFactory;

/**
 * @projectName: com.xiayuanxing.designPattern
 * @className: SimpleFactory
 * @author: xiayuanxing
 * @description: 简单工厂类
 * @date: 2021/12/16 14:48
 * @version: 1.0
 */
public class SimpleFactory {


    public Pizza createPizza(String orderType){

        Pizza pizza = null;

        System.out.println("使用简单工厂模式");

        if(orderType.equals("greek")){
            pizza= new GreekPizza();
            pizza.setName("希腊披萨");
        }else if(orderType.equals("cheese")){
            pizza=new CheesePizza();
            pizza.setName("奶酪披萨");
        }else if(orderType.equals("pepper")){
            pizza=new PepperPizza();
            pizza.setName("胡椒披萨");
        }

        return pizza;
    }

}
